package com.gdziarmaga.webshop.client.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.gdziarmaga.webshop.book.model.Book;
@Entity
@Table(name = "Client_Book")
public class BookClient implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3554973643575129838L;
	private Long book_client_id;
	private Book book;
	private Client client;
	private Integer books_in_basket;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "book_client_seq")
	@SequenceGenerator(name = "book_client_seq", sequenceName = "BOOK_CLIENT_SEQ")
	@Column(name = "book_client_id", precision = 20, scale = 0, unique = true)
	public Long getBook_client_id() {
		return book_client_id;
	}

	public void setBook_client_id(Long book_client_id) {
		this.book_client_id = book_client_id;
	}

	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinColumn(name = "book_id")
	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinColumn(name = "client_id")
	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public void setBooks_in_basket(Integer books_in_basket) {
		this.books_in_basket = books_in_basket;
	}

	@Column(name = "books_in_basket", precision = 20, scale = 0)
	public Integer getBooks_in_basket() {
		return books_in_basket;
	}
}
